package sk.mka.utils.time;

import org.apache.log4j.Logger;

/**
 *
 * @author bracek
 * @date Jul 22, 2010
 */
public class ProgramTime {

    private final long begin;
    private final long beginNano;
    private final static Logger log = Logger.getLogger(ProgramTime.class);

    public ProgramTime() {
        begin = System.currentTimeMillis();
        beginNano = System.nanoTime();

    }

    public void end() {
        long kn = System.nanoTime();
        long k = System.currentTimeMillis();
        long timeInMillis = k - begin;
        converTime(timeInMillis);
        log.info(timeInMillis);

//        long nanoDiff = (kn - beginNano) / 1000000;
//        converTime(nanoDiff);
//        log.info(nanoDiff);

    }

    public static final void converTime(long remdr) {

        final int ms = (int) (remdr % 1000);
        remdr /= 1000;
        final int seconds = (int) (remdr % 60);
        remdr /= 60;
        final int minutes = (int) (remdr % 60);
        remdr /= 60;
        final int hours = (int) (remdr % 24);
        final int days = (int) (remdr / 24);

        System.out.println(days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds " + ms + " miliseconds ");
    }
}
